package main

import "fmt"

// 结构体，类比 java 的 class 类
// 小写就是private
// 大写就是public
type user struct {
	name     string
	password string
}

func main() {
	// 指定每个字段的值
	a := user{name: "wang", password: "1024"}

	// 简写，按顺序对字段赋值
	b := user{"wang", "1024"}

	c := user{name: "wang"}
	c.password = "1024"

	var d user
	d.name = "wang"
	d.password = "1024"

	fmt.Println(a, b, c, d)                 // {wang 1024} {wang 1024} {wang 1024} {wang 1024}
	fmt.Println(checkPassword(a, "haha"))   // false
	fmt.Println(checkPassword2(&a, "haha")) // false
}

func checkPassword(u user, password string) bool {
	return u.password == password
}

func checkPassword2(u *user, password string) bool {
	return u.password == password
}
